package string;
/*StringBuilder的演示*/
public class StringBuilderDemo {
    public static void main(String[] args) {
        String str="好好学习java!";
        StringBuilder builder =new StringBuilder(str);
        builder.append("然后去搬砖");
        System.out.println(builder);



        builder.replace(10,15,"后去扛草包");
        System.out.println(builder);


        builder.delete(0,8);
        System.out.println(builder);


        builder.insert(0,"希望你还健在");
        System.out.println(builder);//增删改插；














        //StringBuilder创建方式：
     StringBuilder builder1=new StringBuilder();
        StringBuilder builder2=new StringBuilder("abc");

        //String和StringBuilder方式互相转换:
      String str1="abc";
      StringBuilder builder3=new StringBuilder(str1);
      String str2=builder3.toString();

    }
}
